<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"  %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>    

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>我的收藏</title>
<link rel="stylesheet" href="css/myPublish.css" />
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
var memId="${sessionScope.existUser.id}";
var deleteMsg="${deleteMsg}";
$(function(){
	if(deleteMsg){
		alert(deleteMsg);
	}	
	var $lis=$(".allLeft ul li");
	$lis.eq(2).children().addClass("aHover").parent().siblings().children().removeClass("aHover");
});
function del(id){
	var flag=confirm("确定要删除该商品吗？");
	if(flag){
		window.location.href="<%=basePath%>"+"member_deleteCollect?favo.id="+id+"&member.id="+memId;
	}else{
		return false;
	}
}
function checkAll(){
	
}
</script>
</head>
<body>
	<jsp:include page="frame.jsp"></jsp:include>
	<div class="allPublishes">
		<jsp:include page="personInfoLeftPart.jsp"></jsp:include>
		<div class="publishes">
			<div class="head">
				<span>我的收藏</span>
				<span class="deleteChecked" style="margin-left:45px; line-height: 35px; color: red; padding:0 10px; cursor: pointer;">删除</span>
			</div>
			<ul class="title">
				<li class="checkboxAll"><input type="checkbox" name="checkboxAll" onclick="checkAll()" id="checkboxAll" /></li>
				<li>图片</li>
				<li>标题</li>
				<li>发布时间</li>
				<li>发布人</li>
				<li>操作</li>
			</ul>
			<div class="myPublish">
				<c:if test="${empty memComms }">
					<span>您还没有收藏任何商品。</span>
				</c:if>
				<c:if test="${!empty memComms }">
					<c:forEach var="memCom" items="${memComms }" varStatus="status">
						<ul class="onePublish">
							<li class="checkboxAll"><input type="checkbox" value="${memCom.favorite.id}" /></li>
							<li><a href="javascript:void(0);"><img src="${memCom.commo.headimgUrl }" /></a></li>
							<li><a href="javascript:void(0);">${fn:substring(memCom.commo.name,0,25) }</a></li>
							<li><a href="javascript:void(0);">${memCom.commo.issueTime }</a></li>
							<li><a href="javascript:void(0);" title="${memCom.member.nickName }">${fn:substring(memCom.member.nickName,0,16) }</a></li>
							<li><a href="commodityInfo_viewDetails?commId=${memCom.commo.id }&commMemberId=${memCom.commo.memberId}">查看</a>&nbsp;<a href="javascript:void(0);" onclick="del(${memCom.favorite.id})">删除</a></li>
						</ul>
					</c:forEach>
				</c:if>				
			</div>
			<div class="page">
				第${pageBean.pageNum}/${pageBean.totalPage }页&nbsp;&nbsp; 
				<a href="member_getCollections?pageNum=1&member.id=${sessionScope.existUser.id}">首页</a>&nbsp;&nbsp; 
				<a href="member_getCollections?pageNum=${pageBean.pageNum-1<1?1:pageBean.pageNum-1}&member.id=${sessionScope.existUser.id}">上一页</a>&nbsp;&nbsp;
				<a href="member_getCollections?pageNum=${pageBean.pageNum+1>pageBean.totalPage?pageBean.totalPage:pageBean.pageNum+1}&member.id=${sessionScope.existUser.id}">下一页</a>&nbsp;&nbsp; 
				<a href="member_getCollections?pageNum=${pageBean.totalPage}&member.id=${sessionScope.existUser.id}">尾页</a>&nbsp;&nbsp; 
				第<input type="text" size="3" name="num" id="num" value="" />页 <a href="javascript:void(0)" onclick="jump('member_getCollections?pageNum=')">跳转</a>
				<script type="text/javascript">
					function jump(path){
						var str="${sessionScope.existUser.id}";
					    var num = document.getElementById("num").value;
					    //保证是自然整数
					    var regObj = /^[1-9][0-9]*$/;
					    if(!regObj.test(num)){
						    alert("请输入自然整数");
						    return;
					    }
					    //还要小于总页数
					    if(num > "${page.totalPage}"){
						    alert("页码超出范围");
						    return;
					    }
					    //都满足才跳转
					    window.location.href="<%=basePath%>" + path + num+'&member.id='+str;
						}
				</script>
			</div>
		</div>
	</div>
	<jsp:include page="foot.jsp"></jsp:include>
</body>
</html>